import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'

//引入node的路径模块
/**
 * pnpm i @types/node --save-dev
 */
import path from 'path'
import Components from 'unplugin-vue-components/vite'
import {
    ElementPlusResolver,
    AntDesignVueResolver,
    VantResolver,
    HeadlessUiResolver,
    ElementUiResolver
} from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({

    //src 别名配置
    resolve: {
        alias: {
            "@": path.resolve(__dirname, "src")
        }
    },

    plugins: [
        vue(),
        Components({
            // ui库解析器，也可以自定义
            resolvers: [
                ElementPlusResolver(),
                AntDesignVueResolver(),
                VantResolver(),
                HeadlessUiResolver(),
                ElementUiResolver()
            ]
        })
    ],


    css: {
        // SCSS 预处理器
        preprocessorOptions: {
            //define global scss variable
            scss: {
                javascriptEnabled: true,
                additionalData: `
            @use "@/styles/variables.scss" as *;
          `,
            },
        },
    },
})
